﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraGrid;
using HFK.DxFluentUI.HorizontalGrid.Columns;
using HFK.DxFluentUI.HorizontalGrid.View;
using HFK.DxFluentUI.DataProvider;
using HFK.DxFluentUI.HorizontalGrid.ComponentModel;
using HFK.DxFluentUI.LanguageModel;

namespace HFK.DxFluentUI.HorizontalGrid
{
  public class HorizontalGridControlBase
  {
    #region public members

    public GridControl Get
    {
      get { return m_implementingControl; }
    }

    public ViewContext<T> View<T>(string caption) where T : class
    {
      ViewContext<T> viewContext = ViewContext<T>.Create(this, caption, 0);
      m_implementingControl.MainView = viewContext.ImplementingControl;
      m_implementingControl.ViewCollection.Add(viewContext.ImplementingControl);
      viewContext.ImplementingControl.GridControl = m_implementingControl;

      return viewContext;
    }

    public ViewContext<T> View<T>(string caption, Action<ViewContext<T>> apply) where T : class
    {
      ViewContext<T> viewContext = ViewContext<T>.Create(this, caption, 0);
      m_implementingControl.MainView = viewContext.ImplementingControl;
      m_implementingControl.ViewCollection.Add(viewContext.ImplementingControl);
      viewContext.ImplementingControl.GridControl = m_implementingControl;

      apply(viewContext);

      return viewContext;
    }

    #endregion

    #region internal members

    internal HorizontalGridControl ImplementingControl { get { return m_implementingControl; } }

    #endregion

    #region private members

    HorizontalGridControl m_implementingControl = new HorizontalGridControl();
    DataProviderList m_dataProvider = new DataProviderList();
    
    #endregion
  }
}
